<div class="content-wrapper">
    <?php
    $form = $this->form;
    $form->prepare();


    ?>
    <?php echo $this->form()->openTag($form); ?>
    <section class="content-header">
        <?php echo $this->partial('layout/breadcrumb'); ?>

        <h1 class="pull-right" id="dbshop-menu-top">
            <a href="<?php echo $this->url('cms-single');?>" class="btn btn-default btn-sm"><i class="fa fa-arrow-left"></i> <?php echo $this->translate('返回单页列表'); ?></a>
            <button type="submit" class="btn btn-primary btn-sm"><i class="fa fa-check"></i> <?php echo $this->translate('保存单页文章'); ?></button>
            <?php echo $this->HelpUrl('cmsClass'); ?>
        </h1>
    </section>

    <section class="content">

        <div class="row">
            <div class="col-md-12">
                <div class="nav-tabs-custom">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#tab_1" data-toggle="tab"><?php echo $this->translate('基本信息'); ?></a></li>
                        <li><a href="#tab_2" data-toggle="tab"><?php echo $this->translate('SEO优化'); ?></a></li>
                    </ul>
                    <div class="tab-content">
                        <?php echo $this->partial('layout/messages'); ?>
                        <div class="tab-pane active" id="tab_1">
                            <div class="box-body">
                                <div class="form-group">
                                    <label class="col-sm-2 control-label"><?php echo $this->translate('文章标题'); ?><span class="must_add_value">*</span></label>
                                    <div class="col-sm-6">
                                        <?php echo $this->formElement($form->get('singleCmsTitle')); ?>
                                        <?php echo $this->formElementErrors($form->get('singleCmsTitle'), ['class'=>'error-message']); ?>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label"><?php echo $this->translate('文章标签'); ?></label>
                                    <div class="col-sm-3">
                                        <?php echo $this->formElement($form->get('singleTag')); ?>
                                        <?php echo $this->formElementErrors($form->get('singleTag'), ['class'=>'error-message']); ?>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label"><?php echo $this->translate('排序'); ?><span class="must_add_value">*</span></label>
                                    <div class="col-sm-2">
                                        <?php echo $this->formElement($form->get('singleCmsSort')); ?>
                                        <?php echo $this->formElementErrors($form->get('singleCmsSort'), ['class'=>'error-message']); ?>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label"><?php echo $this->translate('文章内容'); ?></label>
                                    <div class="col-sm-10">
                                        <script id="singleCmsBody" name="singleCmsBody" type="text/plain"><?php echo isset($this->singleCmsInfo) ? $this->singleCmsInfo->getSingleCmsBody() : $form->get('singleCmsBody')->getValue(); ?></script>
                                        <?php echo $this->formElementErrors($form->get('singleCmsBody'), ['class'=>'error-message']); ?>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="tab-pane" id="tab_2">
                            <div class="box-body">
                                <div class="form-group">
                                    <label class="col-sm-2 control-label"><?php echo $this->translate('扩展名称'); ?></label>
                                    <div class="col-sm-8">
                                        <?php echo $this->formElement($form->get('singleCmsExtendTitle')); ?>
                                        <?php echo $this->formElementErrors($form->get('singleCmsExtendTitle'), ['class'=>'error-message']); ?>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label"><?php echo $this->translate('文章关键字'); ?></label>
                                    <div class="col-sm-8">
                                        <?php echo $this->formElement($form->get('singleCmsKeywords')); ?>
                                        <?php echo $this->formElementErrors($form->get('singleCmsKeywords'), ['class'=>'error-message']); ?>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label"><?php echo $this->translate('文章描述'); ?></label>
                                    <div class="col-sm-8">
                                        <?php echo $this->formElement($form->get('singleCmsDescription')); ?>
                                        <?php echo $this->formElementErrors($form->get('singleCmsDescription'), ['class'=>'error-message']); ?>
                                    </div>
                                </div>
                            </div>
                        </div>

                    </div>
                </div>
            </div>

    </section>
    <?php echo $this->form()->closeTag(); ?>
</div>
<?php echo $this->partial('common/editor',['edit_array'=>['singleCmsBody'],'edit_config'=>["initialFrameHeight:450", 'serverUrl:"'.$this->url('editor', ['action'=> 'uEditorUpload', 'type' =>'cms']).'"']]); ?>
<script>
    $(document).ready(function() {
        $("#<?php echo $form->getName(); ?>").validate({
            rules: {
                singleCmsTitle: {
                    required: true
                },
                singleCmsSort: {
                    required: true,
                    number: true,
                    min: 1
                }
            },
            messages: {
                singleCmsTitle: {
                    required: "<?php echo $this->translate('文章标题不能为空!'); ?>"
                },
                singleCmsSort: {
                    required: "<?php echo $this->translate('排序不能为空!'); ?>",
                    number: "<?php echo $this->translate('排序必须为数字!'); ?>",
                    min: "<?php echo $this->translate('排序最小为1!'); ?>"
                }
            }
        });
    });
</script>
